/***************************************************************************
 *  Filename: remoteprocess.h
 *  Class: RemoteProcess
 *
 *  Copyright 2012  Xander van Kooten
 *  <xandervk@gmail.com>
 *
 *  Copyright 2012  Mario Henrique Voorsluys
 *  <forcaeluz@gmail.com>
 *
 ****************************************************************************/

/*
 *
 * This file is part of Parsax-Remote-Controller.
 *
 *    Parsax-Remote-Controller is free software: you can redistribute it
 *    and/or modify it under the terms of the GNU General Public License
 *    as published by the Free Software Foundation, either version 3 of the
 *    License, or (at your option) any later version.
 *
 *    Parsax-Remote-Controller is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with Parsax-Remote-Controller.
 *    If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef REMOTEPROCESS_H
#define REMOTEPROCESS_H

#include <QObject>
#include <QStringList>
/*!
 \brief Class that represents a process running on the slave.

*/
class RemoteProcess : public QObject
{
    Q_OBJECT
public:
    /*!
     \brief Object constructor

     \param parent
    */
    explicit RemoteProcess(QObject *parent = 0);

    /*!
     \brief Set process identifier

     \param tid The ID given to the program (not the pid)
    */
    void setId(QString tid);

    /*!
     \brief Set host identifier

     \param pc The ID given to the PC
    */
    void setPc(QString pc);

    /*!
     \brief Set program identifier

     \param tprogram The ID given to the program
    */
    void setProgram(QString tprogram);

    /*!
     \brief Set the parameters (arguments) given to the program at startup.

     \param tparams The arguments list.
    */
    void setParameters(QStringList tparameters);

    /*!
     \brief Set the status of the process (program).

     \param tstatus The process status (starting/running/notrunning).
    */
    void setStatus(QString tstatus);

    /*!
     \brief Read variable function

     \return QString The ID of the program
    */
    QString getId();

    /*!
     \brief Read variable function

     \return QString The PC ID (name)
    */
    QString getPc();

    /*!
     \brief Read variable function.

     \return QString The program that should be started
    */
    QString getProgram();

    /*!
     \brief Read variable function.

     \return QString The parameters to start the program (String form)
    */
    QString getParametersString();

    /*!
     \brief Read variable function.

     \return QStringList The parameters to start the program (QStringList form)
    */
    QStringList getParameters();

    /*!
     \brief Read variable function.

     \return QString Process status.
    */
    QString getStatus();

    /*!
     \brief Emitted when the process returns command line output.

     \param type Message type (normal=0, error=1)
     \param message The received message itself
    */
    void newCloReceived(int type, QString message);



signals:
    /*!
     \brief Emitted when changes are made to variables

     Whenever a private variable is changed by using the setter functions, this signal is emitted.
    */
    void infoUpdated();

    /*!
     \brief Emitted when the process sends command line output.

     \param id The ID given to the program.
     \param message The message itself.
    */
    void cloReceived(int id, QString message);

    /*!
     \brief Emitted when a process should be started.

     \param id The ID of the program that is to be started
    */
    void startMe(QString id);

    /*!
     \brief Emitted when a process should be stopped

     \param id The ID of the program that is to be stopped
    */
    void stopMe(QString id);

public slots:
    /*!
     \brief Stop the process.

    */
    void stopProcess();

    /*!
     \brief Start the process.

    */
    void startProcess();
private:
    QString mypc; /*!< The remote PC identifier */
    QString myid; /*!<  The process id */
    QString program; /*!< The program that should be started */
    QStringList parameters; /*!< List with program start arguments */
    QString status; /*!< Current status of the program (starting/running/notrunning) */

private slots:

};

#endif // REMOTEPROCESS_H
